#include "stdafx.h"
#include "HuffmanFunc.h"
#include "CnodeType.h"

int main()
{
	PQ pq;

	ofstream outFile("CodeTable.txt");
	nodeType *root;
	
	string file = "Huffman.txt";
	
	getFreqTable(file);
	// printFreqTable();

	int n = vaildSymbom();

	//cout<<n<<endl;

	initPQ(n, pq);
	
	root = huffman(n, pq);
		
	outFile<<n<<endl;
	makeCode(root, 1, 1, outFile);

	string comFile = "compFile.txt";
	
	encodeText(file, comFile);
	
	outFile.close();

	deCording();
	return 0;
}